<form id="form_add_clockin_activity_in_m65" enctype="multipart/form-data" method="post" action="#" class="form">
    <input type="hidden" name="datagrid_code" value="clockin_activity_m65" />
    <input type="hidden" name="content_type" value="3" />
    <div class="wrapper-form" id="form_content_add_clockin_activity_in_m65"></div>
    <dl class="row">
        <dt class="tit">
            <label>电影</label>
        </dt>
        <dd class="opt">
            <input type="text" id="form_field_search_keyword_movie_in_m65" class="input-txt" />
            <input type="text" name="subject_id" id="form_field_input_subject_id_in_m65" class="input-txt" />
        </dd>
    </dl>
</form>
<script>
    $(function(){
        var subjectKeyword = "clockin_activity_in_m65";
        var datagridCode = "clockin_activity_m65";
        var formId = "#form_add_" + subjectKeyword;
        var formHtml = $(formId).autoProduceFormHtml(datagridCode, 'add');

        // formHtml += ' <dl class="row">' +
        //     '            <dt class="tit">' +
        //     '                <label>状态</label>' +
        //     '            </dt>' +
        //     '            <dd class="opt">' +
        //     '                <label><input type="radio" value="1" checked="checked" name="status">启用</label>' +
        //     '                <label><input type="radio" value="3" name="status">下架</label>' +
        //     '                <span class="err"></span>' +
        //     '            </dd>' +
        //     '        </dl>';

        var formContentId = "#form_content_add_" + subjectKeyword;
        $(formContentId).html(formHtml);
        $.parser.parse(formContentId);

        var movieOption = getMovieOption();
        var movieComboboxConfig = {
            data: movieOption,
            textField: "movie_name_cn",
            valueField: "id"
        };
        $("#form_field_input_subject_id_in_m65").combobox(movieComboboxConfig);

        $("#form_field_search_keyword_movie_in_m65").textbox({
            width:80,
            onChange: function(newValue, oldValue){
                console.log("new value:", newValue);
                console.log("old value:", oldValue);
                var newOption = getMovieOption(newValue);
                movieComboboxConfig.data = newOption;
                $("#form_field_input_subject_id_in_m65").combobox(movieComboboxConfig);
            }
        });

        function getMovieOption(keyword)
        {
            var movieList = [];
            $.ajax({
                url: '/api/LibMovie/getLibMovieOption',
                async: false,
                type:'post',
                data:{movie_name_cn:keyword},
                success:function(resp){
                    if( 1 == resp.code ){
                        movieList = resp.data;
                    }
                }
            });
            return movieList;
        }
    });
</script>
